<template>
  <div>
    <a-card :bordered="false">
      <f-search-form :more="false" @searchHandler="searchHandler">
        <f-search-form-item label="标题" name="verTitle"/>
      </f-search-form>
      <f-table ref="table" size="default" rowKey="logisticsId" :columns="columns" :multiple="false" :operator="operator" :params="queryParam" :api="api.logistics">

        <span slot="action" slot-scope="text, record">
          <template>
            <a @click="$refs.modal.handleShow(record)">编辑</a>
            <a-divider type="vertical"/>
          </template>
          <a-dropdown>
            <a class="ant-dropdown-link">
              更多 <a-icon type="down"/>
            </a>
            <a-menu slot="overlay">
              <a-menu-item v-if="$auth('table.delete')">
                <a href="javascript:;" @click="$refs.table.remove(record.logisticsId)">删除</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </f-table>
      <logistics-drawer ref="modal"></logistics-drawer>
    </a-card>
  </div>
</template>

<script>

  import LogisticsDrawer from './logistics_drawer'

  export default {
    name: 'TableList',
    components: {
      LogisticsDrawer
    },
    data() {
      let me = this
      return {
        //列表初始化查询参数
        queryParam: {
          verTitle: ''
        },
        // 表头
        columns: [
          {
            title: '公司名称',
            dataIndex: 'logisticsName',
            align: 'center'
          },
          {
            title: '公司编号',
            dataIndex: 'logisticsNo',
            align: 'center'
          },
          {
            title: '操作',
            dataIndex: 'action',
            scopedSlots: { customRender: 'action' }
          }
        ],
        //操作按钮
        operator: [
          {
            name: '添加',
            icon: 'plus',
            that: this,
            handler: function(table, that) {
              that.$refs.modal.handleShow()
            }
          },
          {
            name: '删除',
            icon: 'delete',
            batch: true,
            handler: function(table) {
              table.remove()
            }
          }
        ]
      }
    },
    created() {

    },
    methods: {
      setForceUpdate(check, record) {
        this.http.post(this, {
          url: this.api.version.setForceUpdate,
          data: {
            ids: record.versionId,
            forceUpdate: Number(check)
          },
          success(me, data) {
            record.forceUpdate = data
          }
        })
      }
    }

  }
</script>
